﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimaryAlgorithm.Rotate
{
    class MainProject
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 7, 1, 5, 3, 6, 4 };
            Rotate(nums,10);
            foreach (var item in nums)
            {
                Console.WriteLine(item);
            }
            Console.ReadKey();
        }
        public static void Rotate(int[] nums, int k)
        {
            Queue<int> queue = new Queue<int>();
            int index = 0;
            int count = 0;
            while (count< nums.Length+k)
            {
                index = index >= nums.Length ? index - nums.Length : index;
                if (index < k && count<k)
                {
                    queue.Enqueue(nums[index]);
                }
                else
                {
                    queue.Enqueue(nums[index]);
                    nums[index] = queue.Dequeue();
                }
                index++;
                count++;
            }



        }
    }
}
